<template>
  <div class="wrapper">
    <MyNavBar></MyNavBar>
    <van-sticky>
      <van-tabs
        line-width="60px"
        line-height="1px"
        title-active-color="#ff5f16"
        color="#ff5f16"
        @click-tab="onClickTab"
      >
        <van-tab title="正在热映"></van-tab>
        <van-tab title="即将上映"></van-tab>
      </van-tabs>
    </van-sticky>
    <RouterView />
  </div>
</template>

<script setup>
import { useRouter } from "vue-router";
import MyNavBar from "../components/MyNavbar.vue";

const router = useRouter();

const onClickTab = ({ name }) => {
  console.log(name);
  /* 根据序号跳转不同的页面 */
  if (name === 0) {
    router.push("/movie/nowplaying");
  } else {
    router.push("/movie/coming");
  }
};

</script>

<style lang="scss" scoped>
.title {
  text-align: center;
  margin: 30px;
}

.wrapper {
  // margin-bottom: 50px;
  .tabs {
    display: flex;
    // border-bottom: 1px solid #eee;
    .tab {
      flex-grow: 1;
      height: 50px;
      line-height: 50px;
      text-align: center;
    }
  }
}
</style>
